package com.yuetong.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.employee.domain.YtEmployeeEntryInfo;
import com.yuetong.employee.service.IYtEmployeeEntryInfoService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 入职信息Controller
 * 
 * @author  卓晓君
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/employee/entryInfo")
public class YtEmployeeEntryInfoController extends BaseController
{
    @Autowired
    private IYtEmployeeEntryInfoService ytEmployeeEntryInfoService;

    /**
     * 查询入职信息列表
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtEmployeeEntryInfo ytEmployeeEntryInfo)
    {
        startPage();
        List<YtEmployeeEntryInfo> list = ytEmployeeEntryInfoService.selectYtEmployeeEntryInfoList(ytEmployeeEntryInfo);
        return getDataTable(list);
    }

    /**
     * 导出入职信息列表
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:export')")
    @Log(title = "入职信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtEmployeeEntryInfo ytEmployeeEntryInfo)
    {
        List<YtEmployeeEntryInfo> list = ytEmployeeEntryInfoService.selectYtEmployeeEntryInfoList(ytEmployeeEntryInfo);
        ExcelUtil<YtEmployeeEntryInfo> util = new ExcelUtil<YtEmployeeEntryInfo>(YtEmployeeEntryInfo.class);
        util.exportExcel(response, list, "入职信息数据");
    }

    /**
     * 获取入职信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:query')")
    @GetMapping(value = "/{entryId}")
    public AjaxResult getInfo(@PathVariable("entryId") Long entryId)
    {
        return success(ytEmployeeEntryInfoService.selectYtEmployeeEntryInfoByEntryId(entryId));
    }

    /**
     * 新增入职信息
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:add')")
    @Log(title = "入职信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtEmployeeEntryInfo ytEmployeeEntryInfo)
    {
        return toAjax(ytEmployeeEntryInfoService.insertYtEmployeeEntryInfo(ytEmployeeEntryInfo));
    }

    /**
     * 修改入职信息
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:edit')")
    @Log(title = "入职信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtEmployeeEntryInfo ytEmployeeEntryInfo)
    {
        return toAjax(ytEmployeeEntryInfoService.updateYtEmployeeEntryInfo(ytEmployeeEntryInfo));
    }

    /**
     * 删除入职信息
     */
    @PreAuthorize("@ss.hasPermi('employee:entryInfo:remove')")
    @Log(title = "入职信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{entryIds}")
    public AjaxResult remove(@PathVariable Long[] entryIds)
    {
        return toAjax(ytEmployeeEntryInfoService.deleteYtEmployeeEntryInfoByEntryIds(entryIds));
    }
}
